//
//  ViewController.m
//  KVOController的使用总结
//
//  Created by 唐斌 on 2018/6/28.
//  Copyright © 2018年 ruanton. All rights reserved.
//

#import "ViewController.h"
#import <NSObject+FBKVOController.h>
#import "TwoViewController.h"
@interface ViewController ()

@property (weak, nonatomic) IBOutlet UITextField *textField;
@property(nonatomic,strong)FBKVOController* KVOController;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
        NSLog(@"这是主分支才有的");
        NSLog(@"这是主分支才有的2");
    FBKVOController* KVOController = [FBKVOController controllerWithObserver:self];
    self.KVOController = KVOController;
//    _textField.text
    [KVOController observe:self.textField keyPath: @"text" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew block:^(id  _Nullable observer, id  _Nonnull object, NSDictionary<NSString *,id> * _Nonnull change) {
        NSLog(@"change内容是%@",change);
//        change内容是{
//            FBKVONotificationKeyPathKey = text;
//            kind = 1;
//            new = sfg;
//        }
    }];
    
    //监听到值改变后就调用某个方法
//    [self.KVOController observe:self.textField keyPath:@"text" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew action:@selector(updateTextField:)];
    
    
    // Do any additional setup after loading the view, typically from a nib.
}

-(void)updateTextField:(NSDictionary*)textField{
//    _textField.text = @"zansan";
    NSLog(@"textField.text现在的内容是%@",textField);
    
//    textField.text现在的内容是{
//        kind = 1;
//        new = lkkk;
//    }
}

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
    
}

- (IBAction)nextStepBtnClicked:(id)sender {
    TwoViewController* TwoViewC = [[TwoViewController alloc]init];
    [self presentViewController:TwoViewC animated:YES completion:^{
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
